package com.leyou.order.config;

import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConfigImpl;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PayConfiguration {

    /**
     * 生成配置类 ：com.github.wxpay.sdk.WXPayConfigImpl
     */
    @Bean
    @ConfigurationProperties("ly.pay.wx") // 找这个类的返回值的对应的get和set方法
    public WXPayConfigImpl wxPayConfig(){
        return new WXPayConfigImpl();
    }


    /**
     * 生成支付类：com.github.wxpay.sdk.WXPay
     */
    @Bean
    public WXPay wxPay(WXPayConfigImpl wxPayConfig) throws Exception {
        return new WXPay(wxPayConfig);
    }
}
